package com.fone.player.activity.personal;

import java.text.SimpleDateFormat;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.fone.player.R;
import com.fone.player.activity.BaseActivity;
import com.fone.player.activity.main.SplashActivity;
import com.fone.player.entity.NotificationBean;
import com.fone.player.service.NotificationReceiver;
import com.fone.player.util.ActivityQueue;

@SuppressWarnings("unused")
public class NotifyFeedBackActivity extends BaseActivity implements OnClickListener {
	
	private static final String TAG = "FeedBackActivity";
	
	private TextView titleTextView,mUserContentTv,mTVContentTV,mUserDateTV,mTVDateTV;
	private Button leftBt, rightBt,feedback_continue_submit;
	private LinearLayout waitting;
	private Boolean isfromNotification = false;
	private SimpleDateFormat dateFm = new SimpleDateFormat("yyyy-MM-dd");

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.personal_notify_feed_back_view);
		initView();
		initData();
	}

	private void initView() {
		leftBt = (Button) findViewById(R.id.common_title_left_bt);
		rightBt = (Button) findViewById(R.id.common_title_right_bt);
		feedback_continue_submit = (Button) findViewById(R.id.notify_feedback_continue_bt);
		titleTextView = (TextView) findViewById(R.id.common_title_text_tv);
		mUserDateTV = (TextView) findViewById(R.id.notify_user_date_tv);
		mTVDateTV = (TextView) findViewById(R.id.notify_server_date_tv);
		mUserContentTv = (TextView) findViewById(R.id.notify_user_feedback_tv);
		mTVContentTV = (TextView) findViewById(R.id.notify_tv_feedback_tv);
		waitting = (LinearLayout) findViewById(R.id.notify_feedback_waitting_ll);

		leftBt.setText("反馈");

		rightBt.setVisibility(View.GONE);
		titleTextView.setVisibility(View.GONE);
		leftBt.setOnClickListener(this);
		feedback_continue_submit.setOnClickListener(this);

	}
	
	private void initData(){
		Intent intent = getIntent();
		isfromNotification = intent.getBooleanExtra(NotificationReceiver.FROMNOTIFICATION, false);
		NotificationBean niBean = (NotificationBean)intent.getParcelableExtra(NotificationReceiver.NOTIFICATION_INFO);
		
		mUserDateTV.setText(niBean.getNotificationFeedBackTime());
		mTVDateTV.setText(niBean.getNotificationCommentReplyTime());
		mUserContentTv.setText(niBean.getNotificationFeedBackDesc());
		mTVContentTV.setText(niBean.getNotificationContent());
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.common_title_left_bt:
			finish();
			break;
		case R.id.notify_feedback_continue_bt:
			Intent intent = new Intent(this, FeedBackActivity.class);
			startActivity(intent);
			break;

		default:
			break;
		}

	}
	
	@Override
	public void finish() {
		// 未启动应用的通知过来  要打开应用
		if (isfromNotification && ActivityQueue.getSize() <= 1) {
			Intent i = new Intent(NotifyFeedBackActivity.this, SplashActivity.class);
			startActivity(i);
		}
		super.finish();
	}
	
}
